package com.browner.calculator;
import java.io.*;

public class Shutdown {

	public static void shutdown() throws RuntimeException, IOException{
	    int time = 15;
		String shutdownCommand;
	    String operatingSystem = System.getProperty("os.name");

	    if ("Linux".equals(operatingSystem) || "Mac OS X".equals(operatingSystem)) {
	        shutdownCommand = "shutdown -h now";
	    }
	    else if ("Windows".equals(operatingSystem)) {
	        shutdownCommand = "shutdown.exe -s -t " + time;
	    }
	    else {
	        throw new RuntimeException("Unsupported operating system.");
	    }
	    Runtime.getRuntime().exec(shutdownCommand);
	    System.exit(0);
	}

}
